package com.neteast.bustruck.db.entiys

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
import com.neteast.bustruck.http.entiys.ActionUploadInfo
import com.neteast.bustruck.utils.GsonUtils

/**
 * 存当前用户信息
 */
@Entity(tableName = "User")
data class User(
    @PrimaryKey(autoGenerate = true) var uid: Int,
    @SerializedName("access_token")
    @ColumnInfo(name = "accessToken") val token: String?,
    @ColumnInfo(name = "avatar") val avatar: String?,
    @ColumnInfo(name = "email")  val email: String?,
    @ColumnInfo(name = "username")  val username: String
)




@Entity(tableName = "SaveBaseInfo")
data class LocalSaveInfo(
    @PrimaryKey(autoGenerate = true)  var uid:Int,
    //gson化的数据字符串
    @ColumnInfo(name = "data")  var data: String?,
    //获取的那个接口路径
    @ColumnInfo(name = "action") val action:String
)


@Entity(tableName = "truck_load")
data class TmTruckLoadForm(
    @PrimaryKey(autoGenerate = true) var uid:Int,
    @ColumnInfo(name = "username")  val username: String?,
    @ColumnInfo(name = "truck_load_id") val truck_id:String?,

    @ColumnInfo(name = "data") val data:String?,

    //本地采用的指端
    @ColumnInfo(name = "update_time")  var update_time: Long,

    // 是否上传服务器（ 1，创建页面是否上报给服务器来决定该参数）
    @ColumnInfo(name = "isUpdate") var is_update:Boolean=false,

    //日期标签，用于搜索
    @ColumnInfo(name="daytime") val daytime:String?
)


data class TmTruckRequest(var currentTruckLoadId : String?="",var daytime:String?="",var currentCircleId :String="")


data class TmLogUpdateRequest(var currentCircleId :String="")



data class TmActionRequest(var action :String="")




@Entity(tableName = "truck_log")
data class TruckLogInfo(
    @PrimaryKey(autoGenerate = true) var uid:Int,

    @ColumnInfo(name = "username")  val username: String?,
    @ColumnInfo(name = "truck_id") val truck_id:String?,

    @ColumnInfo(name = "current_circle_id ") val currentCircleId :String?,


    @ColumnInfo(name = "data") val data: String?,


    @ColumnInfo(name = "insert_time") val insert_time:Long,
    @ColumnInfo(name = "isUpdate") var is_update:Boolean = false,
){

    fun getUploadInfm(): ActionUploadInfo? {
        var data = GsonUtils.fromJson<ActionUploadInfo>(data,ActionUploadInfo::class.java)
        if(data!=null){
            data.truck_unique_id = truck_id
            data.insert_time = insert_time
        }

        return data
    }

}



data class TruckInfo(
    var position_id:Int?,
    var truck_id:String?,
    val action: Int?,
    val block_id: Int?,
    val block_name: String?,
    val create_time: String?,
    val destination_zone: String?,
    val dig_machine_id: Int?,
    val dig_machine_name: String?,
    val dig_plan_id: Int?,
    val dig_plan_info: DigPlanInfo?,
    val digging_from: String?,
    val employ_id: Int?,
    val employee_name: String?,
    val id: Int?,
    val mark: Int?,
    val material_id: Int?,
    val material_name: String?,
    val project: String?,
    val project_id: Int?,
    val register_time: String?,
    val rel_dig_plan_id: Int?,
    val standby: Int?,
    val status: Int?,
    val tipping: Int?,
    val truck_machine_id: Int?,
    val truck_machine_name: String?,
    val update_time: String?,
    val weight: String?,
    var stand:String?,
    var blast_id:String?,
    val block_number: String?,
)



data class DigPlanInfo(
    val bench_id: String?,
    val block_ids: String?,
    val block_number: String?,
    val blocks: List<Block>?,
    val create_time: String?,
    val date_logged: String?,
    val destination: String?,
    val dig_plan_image: String?,
    val dig_plan_label: String?,
    val `file`: String?,
    val id: Int?,
    val label_vc: String?,
    val mark: Int?,
    val material_id: Int?,
    val materials: List<Any>?,
    val pdf_to_image: String?,
    val pit_id: String?,
    val project: String?,
    val project_id: Int?,
    val rl_from: String?,
    val rl_to: String?,
    val shot_id: String?,
    val status: Int?,
    val title: String?,
    val update_time: String?,
    val shot:String?
)

data class Block(
    val block_id: String?,
    val computer_key: String?,
    val create_time: String?,
    val dig_plan_id: Int?,
    val id: Int?,
    val mark: Int?,
    val material_id: Int?,
    val material_types: String?,
    val project: String?,
    val project_id: Int?,
    val rel_dig_plans: List<RelDigPlan>?,
    val rl_from: String?,
    val rl_to: String?,
    val shot: String?,
    val title: String?,
    val update_time: String?
)

data class RelDigPlan(
    val block_id: Int?,
    val create_time: String?,
    val date_logged: String?,
    val id: Int?,
    val machine_id: Int?,
    val machine_id_text: String?,
    val mark: Int?,
    val material_types: String?,
    val material_types_text: String?,
    val project_id: Int?,
    val project_id_text: String?,
    val update_time: String?,
    val work_shift: Int?
)





